import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import routes from './routes';
import {Route, Switch} from 'react-router-dom';
import Breadcrumb from 'Shell/components/Breadcrumb';
import {Card} from 'antd';
import TablePanel from './TablePanel';
import QueryPanel from './QueryPanel';
import 'ant-design-pro/dist/ant-design-pro.css';
import NoMatchRoute from '../common/NoMatchRoute';
import Add from './Add';
export class App extends PureComponent {
    componentDidMount() {
        this.props.init();
    }

    render() {
        return (
            <div>
                <Route render={props => <Breadcrumb location={props.location} />} />
                <div className="page-main">
                    <Switch>
                        <Route
                            path={routes.query.url()}
                            exact
                            render={() => (
                                <div>
                                    <Card>
                                        <QueryPanel />
                                    </Card>
                                    <Card>
                                        <TablePanel />
                                    </Card>
                                </div>
                            )}/>
                        <Route path={routes.apply.url()} exact render={props =>
                            <Add isCabinet={false} history={props.history} />} />
                        <Route path={routes.reject.url()} exact render={props =>
                            <Add isCabinet={true} history={props.history} />} />
                        <NoMatchRoute link={routes.query.url()} />
                    </Switch>
                </div>
            </div>
        );
    }
}
App.propTypes = {
    history: PropTypes.object,
    init: PropTypes.func,
    loading: PropTypes.bool,
    location: PropTypes.object,
    match: PropTypes.object,
};
import {connect} from 'react-redux';
import {getInitData} from './actions.js';
const mapStateToProps = state => ({
    loading: state.getIn(['page', 'domainData', 'brands', 'isFetching']),
});
const mapDispatchToProps = dispatch => ({
    init: () => dispatch(getInitData())
});

export default connect(
    null,
    mapDispatchToProps
)(App);
